from page_object.pages.BasePage import BasePage
from selenium.webdriver.common.by import By
from page_object.pages.CirclePage import CirclePage
from page_object.pages.MessagePage import MessagePage
from page_object.pages.MyPage import MyPage
from page_object.pages.NearbyPage import NearbyPage
from page_object.pages.PartyPage import PartyPage
from page_object.pages.PeIWanListPage import PeiWanListPage
from page_object.pages.SearchPage import SearchPage


class MainPage(BasePage):
    _app_activity_close_iv = (By.ID, 'app_activity_close_iv')  #关闭广告弹窗按钮
    _tv_search = (By.ID, 'tv_search')   #搜索按钮
    _nearly_view = (By.ID, 'nearly_view')  #同城按钮
    _circle_page = (By.XPATH, '//*[contains(@resource-id, "tv_text") and contains(@text, "圈子")]')
    _party_page = (By.XPATH, '//*[contains(@resource-id, "tv_text") and contains(@text, "派对")]')
    _message_page = (By.XPATH, '//*[contains(@resource-id, "tv_text") and contains(@text, "消息")]')
    _my_page = (By.XPATH, '//*[contains(@resource-id, "tv_text") and contains(@text, "我的")]')
    _peiwan_list = (By.XPATH, '//*[contains(@resource-id, "tv_name") and contains(@text, "王者荣耀")]')


    def update_popup(self):
        '''
        点击更新提示
        :return:
        '''
        self.find_by_xpath('残忍拒绝').click()
        return self

    def advert_popup(self):
        '''
        关闭弹窗广告
        :return:
        '''
        self.find(self._app_activity_close_iv).click()
        return self

    def go_to_search_page(self):
        '''
        去搜索页
        :return:
        '''
        self.find(self._tv_search).click()
        return SearchPage()

    def go_to_nearby_people_page(self):
        '''
        去附近的人页面
        :return:
        '''
        self.find(self._nearly_view).click()
        return NearbyPage()

    def go_to_circle_page(self):
        '''
        去圈子页面
        :return:
        '''
        self.find(self._circle_page).click()
        return CirclePage()

    def go_to_party_page(self):
        '''
        去派对页面
        :return:
        '''
        self.find(self._party_page).click()
        return PartyPage()

    def go_to_message_page(self):
        '''
        去消息页面
        :return:
        '''
        self.find(self._message_page).click()
        return MessagePage()

    def go_to_my_page(self):
        '''
        去我的页面
        :return:
        '''
        self.find(self._my_page).click()
        return MyPage()

    def go_to_peiwan_list(self):
        '''
        去王者荣耀陪玩列表
        :return:
        '''
        self.find(self._peiwan_list).click()
        return PeiWanListPage()







